package com.ruoyi.web.controller.repair;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.data.SysParamKey;
import com.ruoyi.data.domain.ParameterSingleT;
import com.ruoyi.data.service.IParameterSingleService;
import com.ruoyi.project.domain.HouseProjectT;
import com.ruoyi.project.service.IHouseProjectTService;
import com.ruoyi.repairSign.domain.HouseRepairSignT;
import com.ruoyi.repairSign.service.IHouseRepairSignTService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 户资金修改Controller
 *
 * @author tyq
 * @date 2023-05-24
 */
@RestController
@RequestMapping("/repair/repairSign")
public class HouseRepairSignTController extends BaseController {
    @Autowired
    private IHouseRepairSignTService houseRepairSignTService;
    @Autowired
    private IHouseProjectTService houseProjectTService;
    @Autowired
    private IParameterSingleService parameterSingleService;

    /**
     * 查询维修列表
     */
    @GetMapping("/list")
    public TableDataInfo listRepairSign(HouseRepairSignT houseRepairSignT) {
        List<HouseRepairSignT> list = new ArrayList<HouseRepairSignT>();
        HouseProjectT projectVO = new HouseProjectT();
        projectVO=houseProjectTService.selectHouseProjectTByProjectId(houseRepairSignT.getProjectId());
        ParameterSingleT vo = new ParameterSingleT();
        vo.setParamCode(SysParamKey.PHOTO_HTTP.getKey());
        vo = parameterSingleService.getSysParams(vo);
        startPage();
        if(projectVO!=null && "1".equals(projectVO.getProjectSts())){
        }else{
            list = houseRepairSignTService.selectHouseRepairSignTList(houseRepairSignT);
            for(HouseRepairSignT houseRepairSignVO:list){
                houseRepairSignVO.setSignPhotoHttp(vo.getParamVal()+"\\"+houseRepairSignVO.getSignPhotoHttp()+".svg");
            }
        }
        return getDataTable(list);
    }

    @GetMapping("/{projectId}/{houseIds}/{signSts}")
    public AjaxResult edit(@PathVariable("projectId") String projectId,@PathVariable("houseIds") String[] houseIds,@PathVariable("signSts") String signSts) {
        return toAjax(houseRepairSignTService.updateHouseRepairSignT(projectId,houseIds,signSts));
    }


}
